package generator.util;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import lombok.experimental.UtilityClass;

import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author angel.bin@aliyun.com
 * @since 2020-10-05 13:34
 */
@UtilityClass
public class TableMapUtils {
    public String getClassName(String tableName, List<String> tablePrefixes) {
        if (CollUtil.isNotEmpty(tablePrefixes)) {
            for (String tablePrefix : tablePrefixes) {
                tableName = StrUtil.removePrefixIgnoreCase(tableName, tablePrefix);
            }
        }
        return StrUtil.upperFirst(StrUtil.toCamelCase(tableName));
    }

    public String getColumn(String columnName, List<String> columnPrefixes) {
        if (CollUtil.isNotEmpty(columnPrefixes)) {
            for (String columnPrefix : columnPrefixes) {
                columnName = StrUtil.removePrefixIgnoreCase(columnName, columnPrefix);
            }
        }
        return StrUtil.lowerFirst(StrUtil.toCamelCase(columnName));
    }

}
